/// Author: Samle
import 'package:flutter/material.dart';

class HelpTextElement extends StatefulWidget {
  /// 传入参数
  const HelpTextElement({
    Key? key,
    required this.onPressed,
    required this.doublePressed,
    required this.longPressed,
    required this.onTap,
    required this.dataForm,
  }) : super(key: key,);
  final Map dataForm;
  final VoidCallback onPressed;
  final VoidCallback doublePressed;
  final VoidCallback longPressed;
  final VoidCallback onTap;
  @override
  State<StatefulWidget> createState() => HelpTextElementState();
}
class HelpTextElementState extends State<HelpTextElement> {

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment:Alignment.center , /// 指定对齐方式为居中
      children: <Widget>[          /// 子组件列表
        Positioned(                /// 不指定任何参数时则放在Stack对齐方式指定的位置
          child: InkWell(
              onTap: (){ widget.onPressed(); },
              onDoubleTap: (){ widget.doublePressed(); },
              onLongPress: (){ widget.longPressed(); },
              child: Container(
                  padding: EdgeInsets.fromLTRB(8, 4, 8, 4),
                  decoration: BoxDecoration(
                    border:  Border(bottom:BorderSide(width: 1,color: Color(0xffe5e5e5)) ),
                  ),
                  child: Column(
                      children: [

                        Container(
                            padding: EdgeInsets.fromLTRB(8, 2, 8, 2),
                            child: Row(
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Container(
                                        alignment: Alignment.bottomLeft,
                                        child: Text.rich(
                                            TextSpan(
                                                children: [
                                                  TextSpan(text: "内容",style: TextStyle(color: Colors.black87,fontSize: 12)),
                                                ]
                                            )
                                        )
                                    )
                                ),
                                // Expanded(
                                //     flex: 1,
                                //     child: Container(
                                //         alignment: Alignment.bottomLeft,
                                //         child: Text.rich(
                                //             TextSpan(
                                //                 children: [
                                //                   TextSpan(text: "Val",style: TextStyle(color: Colors.black54,fontSize: 12)),
                                //                 ]
                                //             )
                                //         )
                                //     )
                                // ),
                                Expanded(
                                    flex: 4,
                                    child: Container(
                                        alignment: Alignment.bottomLeft,
                                        child: Text.rich(
                                            TextSpan(
                                                children: [
                                                  TextSpan(text: widget.dataForm["val"] != null ? widget.dataForm["val"].toString() : '',style: TextStyle(color: Colors.black54,fontSize: 12)),
                                                ]
                                            )
                                        )
                                    )
                                ),
                              ],
                            )
                        ),
                        Container(
                            padding: EdgeInsets.fromLTRB(8, 2, 8, 2),
                            child: Row(
                              children: [
                                Expanded(
                                    flex: 1,
                                    child: Container(
                                        alignment: Alignment.bottomLeft,
                                        child: Text.rich(
                                            TextSpan(
                                                children: [
                                                  TextSpan(text: "说明",style: TextStyle(color: Colors.black87,fontSize: 12)),
                                                ]
                                            )
                                        )
                                    )
                                ),
                                // Expanded(
                                //     flex: 1,
                                //     child: Container(
                                //         alignment: Alignment.bottomLeft,
                                //         child: Text.rich(
                                //             TextSpan(
                                //                 children: [
                                //                   TextSpan(text: "Desc",style: TextStyle(color: Colors.black54,fontSize: 12)),
                                //                 ]
                                //             )
                                //         )
                                //     )
                                // ),
                                Expanded(
                                    flex: 4,
                                    child: Container(
                                        alignment: Alignment.bottomLeft,
                                        child: Text.rich(
                                            TextSpan(
                                                children: [
                                                  TextSpan(text: widget.dataForm["desc"] != null ? widget.dataForm["desc"].toString() : '',style: TextStyle(color: Colors.black54,fontSize: 12)),
                                                ]
                                            )
                                        )
                                    )
                                ),
                              ],
                            )
                        ),
                      ]
                  )
              )
          ),
        ),
        /// Positioned(
        /// right: 15,
        /// top: 0,
        /// child: Container(
        /// child: Text(""),
        /// decoration: BoxDecoration(
        /// borderRadius: BorderRadius.only(
        /// bottomLeft: Radius.circular(5.0),
        /// bottomRight: Radius.circular(5.0)
        /// ),
        /// ),
        /// padding: EdgeInsets.fromLTRB(3, 2, 3, 4),
        /// ),
        /// ),
      ],
    );
  }

}

